<?php
declare (strict_types = 1);

namespace app\controller\api;

use app\BaseController;
use think\Request;

class Message extends BaseController
{

    // 消息列表
    public function getMsgList(){
        $type_list = $this->request->param('type_list',[]);
        $time = time();
        $data = [
            'time' => $time,
            "type_list"=> $type_list,
        ];
        $sign = $this->getSignature($data,config('app.APIKEY'));
        $param = [
            "api_id"=> config('app.APIID'),
            "sign"=> $sign,
            "data"=> $data,
        ];

        $url = 'http://main.miniappss.com/terminal/api.message/getMsgList';

        $res = $this->curlPost($url,$param);
        if(isset($res['code']) && $res['code'] != 200){
            return $this->error([],$res['msg'],$res['error_code']);
        }
        return $this->success($res['data'],$res['msg']);
    }

    // 消息删除
    public function delMsg(){
        $msg_list = $this->request->param('msg_list',[]);
        $time = time();
        $data = [
            'time' => $time,
            "msg_list"=> $msg_list,
        ];
        $sign = $this->getSignature($data,config('app.APIKEY'));
        $param = [
            "api_id"=> config('app.APIID'),
            "sign"=> $sign,
            "data"=> $data,
        ];

        $url = 'http://main.miniappss.com/terminal/api.message/delMsg';

        $res = $this->curlPost($url,$param);
        if(isset($res['code']) && $res['code'] != 200){
            return $this->error([],$res['msg'],$res['error_code']);
        }
        return $this->success($res['data'],$res['msg']);
    }
    

}
